package dbcontext;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import dbhelpers.AlbumHelper;
import dbhelpers.PhotoHelper;
import dbhelpers.UserHelper;

public class Helper extends SQLiteOpenHelper {

	private static final String namedb = "TripMemories.db";

	public Helper(Context context) {
		super(context, namedb, null, 1);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(UserHelper.createTable);
		db.execSQL(AlbumHelper.createTable);
		db.execSQL(PhotoHelper.createTable);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		
		try {
			db.execSQL(UserHelper.dropTable);
		} catch (Exception e) {
		}

		try {
			db.execSQL(AlbumHelper.dropTable);
		} catch (Exception e) {
		}

		try {
			db.execSQL(PhotoHelper.dropTable);
		} catch (Exception e) {
		}
		
		onCreate(db);
	}

	@Override
	public void onOpen(SQLiteDatabase db) {
		super.onOpen(db);
	}
	
	

}
